var netTool
var apiPath = 'capi/V2/ERGoodsManage/erGoodsManage/'

function ERGoodsScan(_netTool) {
	netTool = _netTool
	let user_id = uni.getStorageSync('userInfo').id
	this.list = function(data, fn) {
		if(!data.own_store_id){
			return;
		}
		netTool.getAjaxUrlValueBackground(apiPath + 'list', {
			 ...data,
		}, function(res) {
			typeof fn == 'function' && fn(res);
		})
	}
	this.getProduct  =  function(data,fn){
		netTool.getAjaxUrlValueBackground(apiPath + 'getProduct', {
			...data,
		}, function(res) { 
			typeof fn == 'function' && fn(res);
		})
	}
	this.update = function(data, fn) {
		netTool.getAjaxUrlValueBackground(apiPath + 'update', {
			...data,
		}, function(res) {
			netTool.getAjaxUrlValueBackground(apiPath + 'list',{
				...data,
				created_by:user_id
			}, function(res) {
			typeof fn == 'function' && fn(res);
		})
			// typeof fn == 'function' && fn(res);
		})
	}
	this.save = function(data, fn) {
		netTool.getAjaxUrlValueBackground(apiPath + 'save', {
			...data,
		 
		}, function(res) {
			typeof fn == 'function' && fn(res);
		})
	}
	this.del = function(data, fn) {
		netTool.getAjaxUrlValueBackground(apiPath + 'del', {
			...data,
		 
		}, function(res) {
			typeof fn == 'function' && fn(res);
		})
	}

}
module.exports = ERGoodsScan;
